package ca.uvic.cs.cogz.mapping;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import ca.uvic.cs.cogz.mapping.ontology.DataLoaderFacade;
import ca.uvic.cs.cogz.stats.StatsManager;
import ca.uvic.cs.cogz.util.IconConstants;
import edu.stanford.smi.protege.model.KnowledgeBase;
import edu.stanford.smi.protegex.prompt.plugin.util.KnowledgeBaseFacade;

public class ViewMappingsAction extends AbstractAction {
	private static final long serialVersionUID = -5518911697348597764L;

	/** reference to the manager for temporary mappings, necessary for passing to mapping UI */
	private TemporaryMappingManager temporaryMappingManager;

	/** reference to the manager for suggested mappings, necessary for passing to mapping UI */
	private SuggestionsManager suggestionsManager;

	/** reference to the managers for cls statistics, necessary for passing to mapping UI */
	private StatsManager sourceStatsManager;
	private StatsManager targetStatsManager;

	public ViewMappingsAction(TemporaryMappingManager temporaryMappingManager, SuggestionsManager suggestionsManager, StatsManager sourceStatsManager, StatsManager targetStatsManager) {
		super("Visualize mappings", IconConstants.ICON_VISUALIZE_MAPPING);

		this.temporaryMappingManager = temporaryMappingManager;
		this.suggestionsManager = suggestionsManager;
		this.sourceStatsManager = sourceStatsManager;
		this.targetStatsManager = targetStatsManager;
	}

	public void actionPerformed(ActionEvent e) {
		KnowledgeBase sourceKb = KnowledgeBaseFacade.getMappingSourceKnowledgeBaseInMerging().getKnowledgeBase();
		KnowledgeBase targetKb = KnowledgeBaseFacade.getMappingTargetKnowledgeBaseInMerging().getKnowledgeBase();
		KnowledgeBase mappingKb = KnowledgeBaseFacade.getMappingKnowledgeBase().getProject().getKnowledgeBase();

		DataLoaderFacade.getInstance().loadMapping(sourceKb, targetKb, mappingKb, temporaryMappingManager, suggestionsManager, sourceStatsManager, targetStatsManager);
	}
}
